Skip to content

Conversation

@trisdoan
Copy link
Contributor

No description provided.

@trisdoan trisdoan force-pushed the 17.0-add-mail_activity_default_assignee branch from 03791fc to 2a07a82 Compare November 27, 2024 04:54
@github-actions
Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 30, 2025
Copy link

@ivantodorovich ivantodorovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add unit tests?

"ir.model.fields",
domain=f"""
[
("name", "not in", {str(MAGIC_FIELDS)}),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the magic fields are discarded by the ttype leaf, with exception of create_uid and write_uid.
So, I'm wondering, why don't we allow using these for the activity default user field?

Suggested change
("name", "not in", {str(MAGIC_FIELDS)}),

[
("name", "not in", {str(MAGIC_FIELDS)}),
("ttype", "in", ["one2many","many2one", "many2many"]),
("model_id", "=", model_id),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
("model_id", "=", model_id),
("model_id.model", "=", res_model),

with this change I think we no longer need the model_id field, and so you could drop it to keep it simpler

Comment on lines 38 to 40
self.default_user_field_id = self.default_user_field_id.filtered(
lambda field: field.model_id.model == self.res_model
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to avoid reassigning value for no reason

Suggested change
self.default_user_field_id = self.default_user_field_id.filtered(
lambda field: field.model_id.model == self.res_model
)
if self.default_user_field_id.model_id.model != self.res_model:
self.default_user_field_id = False

Comment on lines 18 to 22
res_model = self.env[scheduler.res_model]
user_ids = scheduler._get_user_ids(res_model, fname)
if not user_ids:
continue
scheduler.activity_user_id = user_ids[0]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can simplify this bit by reusing some internal methods.
You can drop the _get_user_ids, too..

Suggested change
res_model = self.env[scheduler.res_model]
user_ids = scheduler._get_user_ids(res_model, fname)
if not user_ids:
continue
scheduler.activity_user_id = user_ids[0]
if users := scheduler._get_applied_on_records().mapped(fname):
scheduler.activity_user_id = users[:1]

ℹ️ requirement: add @api.depends('res_ids')


def _get_user_ids(self, model, fname):
context = self.env.context
active_id = context.get("active_id")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my previous proposal about dropping this in favor of calling _get_applied_on_records, which is based on the record res_ids field

@github-actions github-actions bot removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Apr 6, 2025
@trisdoan trisdoan force-pushed the 17.0-add-mail_activity_default_assignee branch from 2a07a82 to f36b067 Compare April 28, 2025 09:23
@trisdoan trisdoan requested a review from ivantodorovich April 28, 2025 09:23
@trisdoan
Copy link
Contributor Author

Hello @ivantodorovich, thanks for your review. I updated, could you take a look please?

if not rec.res_model:
rec.model_id = False
continue
rec.model_id = self.env["ir.model"]._get_id(rec.res_model)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left-over code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh ja, thanks, I updated

@trisdoan trisdoan force-pushed the 17.0-add-mail_activity_default_assignee branch from f36b067 to 250aa06 Compare April 29, 2025 01:12
@trisdoan trisdoan requested a review from ivantodorovich April 29, 2025 01:13
Copy link

@ivantodorovich ivantodorovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!


from odoo import api, fields, models

MAGIC_FIELDS = models.MAGIC_COLUMNS

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this?

Comment on lines 14 to 15
domain="[('ttype','in', ['one2many', 'many2one', 'many2many']),"
"('model','=',res_model), ('relation', '=', 'res.users')]",
Copy link

@SilvioC2C SilvioC2C May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add this domain in the view since it's evaluated according to the res_model field value, and add a constraint instead to check whether default_user_field_id is a feasible field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @SilvioC2C, it's actually a good idea, we can get rid of onchange

@trisdoan trisdoan force-pushed the 17.0-add-mail_activity_default_assignee branch from 250aa06 to 5b6f429 Compare May 23, 2025 08:25
@trisdoan trisdoan force-pushed the 17.0-add-mail_activity_default_assignee branch from 5b6f429 to 2e60b15 Compare May 23, 2025 08:38
@trisdoan trisdoan requested a review from SilvioC2C May 23, 2025 08:45
@github-actions
Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Sep 21, 2025
@github-actions github-actions bot closed this Oct 26, 2025
@vvrossem
Copy link
Contributor

Hello @hbrunn, my apologies for pinging you directly. Could you please reopen this PR and apply the "no stale" label? 🙏

@yankinmax
Copy link

Hello @SilvioC2C can you pls retake a look at this PR after it was updated?

@yankinmax
Copy link

Hello @pedrobaeza, my apologies for pinging you directly.
Could you please reopen this PR and apply the "no stale" label? 🙏

@pedrobaeza pedrobaeza reopened this Jan 21, 2026
@pedrobaeza pedrobaeza removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants